package cn.px.hro.payment_form_file.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.px.common.utils.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.px.common.annotation.Log;
import cn.px.common.core.controller.BaseController;
import cn.px.common.core.domain.AjaxResult;
import cn.px.common.enums.BusinessType;
import cn.px.hro.payment_form_file.domain.HroPaymentFormFile;
import cn.px.hro.payment_form_file.service.IHroPaymentFormFileService;
import cn.px.common.utils.poi.ExcelUtil;
import cn.px.common.core.page.TableDataInfo;

/**
 * 付款单附件Controller
 *
 * @author ruoyi
 * @date 2023-08-12
 */
@RestController
@RequestMapping("/paymentformfile/paymentformfile")
public class HroPaymentFormFileController extends BaseController
{
    @Autowired
    private IHroPaymentFormFileService hroPaymentFormFileService;

    /**
     * 查询付款单附件列表
     */
//    @PreAuthorize("@ss.hasPermi('paymentformfile:paymentformfile:list')")
    @GetMapping("/list")
    public TableDataInfo list(HroPaymentFormFile hroPaymentFormFile)
    {
        startPage();
        List<HroPaymentFormFile> list = hroPaymentFormFileService.selectHroPaymentFormFileList(hroPaymentFormFile);
        return getDataTable(list);
    }

    /**
     * 导出付款单附件列表
     */
//    @PreAuthorize("@ss.hasPermi('paymentformfile:paymentformfile:export')")
    @Log(title = "付款单附件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HroPaymentFormFile hroPaymentFormFile)
    {
        List<HroPaymentFormFile> list = hroPaymentFormFileService.selectHroPaymentFormFileList(hroPaymentFormFile);
        ExcelUtil<HroPaymentFormFile> util = new ExcelUtil<HroPaymentFormFile>(HroPaymentFormFile.class);
        util.exportExcel(response, list, "付款单附件数据");
    }

    /**
     * 获取付款单附件详细信息
     */
//    @PreAuthorize("@ss.hasPermi('paymentformfile:paymentformfile:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hroPaymentFormFileService.selectHroPaymentFormFileById(id));
    }

    /**
     * 新增付款单附件
     */
//    @PreAuthorize("@ss.hasPermi('paymentformfile:paymentformfile:add')")
    @Log(title = "付款单附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HroPaymentFormFile hroPaymentFormFile)
    {
        return toAjax(hroPaymentFormFileService.insertHroPaymentFormFile(hroPaymentFormFile));
    }

    /**
     * 修改付款单附件
     */
//    @PreAuthorize("@ss.hasPermi('paymentformfile:paymentformfile:edit')")
    @Log(title = "付款单附件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HroPaymentFormFile hroPaymentFormFile)
    {
        return toAjax(hroPaymentFormFileService.updateHroPaymentFormFile(hroPaymentFormFile));
    }

    /**
     * 删除付款单附件
     */
//    @PreAuthorize("@ss.hasPermi('paymentformfile:paymentformfile:remove')")
    @Log(title = "付款单附件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hroPaymentFormFileService.deleteHroPaymentFormFileByIds(ids));
    }
}
